import { prop } from "@typegoose/typegoose";
import { SexType, UserRole } from "../types/user.type";
import { Base } from "./base";


const avatars = [
  'https://img2.baidu.com/it/u=320784683,3750474434&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1682096400&t=ed9fa830183ac28ea5d64a9f30389003',
]

function dafeultAvatar(): string {
  return avatars[Math.floor(Math.random() * avatars.length)]
}

/** 用户类 */
export class User extends Base {

  @prop({})
  email: string;

  @prop({ select: false })
  password: string;

  @prop({})
  name?: string;

  @prop({ default: dafeultAvatar() })
  avatar?: string;

  @prop({})
  nick?: string;

  @prop({})
  phone?: string;

  @prop({})
  birthday?: number;

  /** 座右铭 */
  @prop({})
  motto?: string;

  /** 用户角色 */
  @prop({ default: UserRole.User })
  role: UserRole;

  @prop({ default: SexType.Woman })
  sex?: SexType;
}


